home *** CD-ROM | disk | FTP | other *** search
- Path: scream.ing.com!news
- From: "John C. Lund" <jlund@allaire.com>
- Newsgroups: comp.lang.pascal.delphi.misc,comp.lang.c++
- Subject: Delphi calls to a C++ DLL
- Date: Wed, 31 Jan 1996 14:52:27 -0600
- Organization: Allaire
- Message-ID: <310FD68B.208B@allaire.com>
- NNTP-Posting-Host: 206.144.133.15
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (Win95; I)
-
- I have written a DLL in C++ that I am attempting to call from a Delphi EXE. I can call
- DLL functions from my C++ apps, but not from my Delphi program. The Delphi app calls the
- DLL function, but most of the parameters passed are garbage. I tried the same techniques
- and syntax I found in the Delphi libraries, but to no avail.
-
- For whatever reason it looks like the parameters are pushed and popped from the stack
- differently beween environments. I've tried declaring the function in Delphi with
- "stdcall" and "cdecl", and I've tried other data types in place of pchar. Any
- suggestions?
-
-
- ***************
- Delphi SNIPPETS
- ***************
-
- {type, private}
- function GetFieldsForTable(
- pcharDataSourceName,
- pcharUsername,
- pcharPassword,
- pcharTableName: pChar
- ): integer;
-
- {implementation}
- function TODBCInformant.GetFieldsForTable;
- external 'patrik.dll' name 'GetFieldsForTable';
-
- {I call the function like this:}
- nIndex:= GetFieldsForTable(strpcopy(pcharBuiffer,'Test'),
- strpcopy(pcharBuiffer,''),
- strpcopy(pcharBuiffer,''),
- strpcopy(pcharBuiffer,'Employees'));
-
-
- ************
- C++ SNIPPETS
- ************
-
- // My C++ header (.H) declares the prototype like this:
- extern "C" INT FAR PASCAL EXPORT GetFieldsForTable(
- LPSTR lpszDataSourceName,
- LPSTR lpszUsername,
- LPSTR lpszPassword,
- LPSTR lpszTableName
- );
-
- /*
- My implementation uses the same format, and the function is named in the
- exports section of the .DEF file.
- */
-
-
- // John C. Lund jlund@allaire.com http//:www.allaire.com/
-